/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package coverter;

import entities.Area;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.FacesConverter;

/**
 *
 * @author curso
 */
@FacesConverter("areaconverter")
public class AreaConverter implements Converter{

    @Override
    public Object getAsObject(FacesContext context, UIComponent component, String value) {
        String cad[]=value.split("__");
        Area a=new Area(Integer.parseInt(cad[0]));
        a.setTipo(cad[1]);
        return a;      
        
        
    }

    @Override
    public String getAsString(FacesContext context, UIComponent component, Object value) {
        Area a=(Area)value;
        String s=a.getIdArea()+"__"+a.getTipo();
        return s;
    }
    
    
}
